﻿using System.Erp.Runtime;

namespace System.Erp
{
    /// <summary>
    /// 为某个零件定义一个工作区。
    /// </summary>
    [Serializable]
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
    public sealed class WorkspaceAttribute : Attribute
    {
        /// <summary>
        /// 传入一个工作区字符串来定义工作区，建议使用内置的常量
        /// </summary>
        /// <param name="workspace">工作区字符串，不能为空。</param>
        public WorkspaceAttribute(string workspace)
        {
            if (string.IsNullOrEmpty(workspace))
            {
                throw new ArgumentNullException("workspace");
            }
            _workspace = workspace;
        }

        private readonly Workspace _workspace;
        /// <summary>
        /// 返回定义的工作区
        /// </summary>
        public Workspace Workspace
        {
            get { return _workspace; }
        }
    }
}
